function outHistory(){
	$.ajax({
		url :interfaceMobileUrl+"/outHistory.json?userid="+userid+"&key="+userkey,
		jsonp: "callback",
	    dataType: "jsonp",
	    beforeSend:function(data){
			$("#outHistoryUl").html("");
			$("#outHistoryUl").append(getLoadingLi("正在加载中..."));
		},
		error:function(data){
			$("#outHistoryUl").html("");
			$("#outHistoryUl").append(getNoneDataLi("网络连接失败..."));
		},
		success:function(data){
			var loans = eval('(' + data + ')');
			loans = loans.list[0]["com.opac.readerHome.domain.UdlsHistory"];
			$("#outHistoryUl").html("");
			if(loans == undefined){
				$("#outHistoryUl").append(getNoneDataLi("您暂时还没有转借借出历史"));
				return ;
			}
			if(loans.length==undefined){
				loans = [loans];
			}
			for(var i = 0;i<loans.length;i++){
				var title = loans[i].title;
				var author = loans[i].author;
				var isbn = loans[i].isbn;
				var fromCommentId = loans[i].fromCommentId;
				var toCommentId = loans[i].toCommentId;
				var li="<li>"+
                       "<a class0='"+loans[i].class0+"' publisher='"+loans[i].publisher+"' isbn='"+isbn+"' title='"+title+"' author='"+author+"' href='#sjxqdt'>"+
                            "<img isbn="+isbn+" src='images/default1.jpg'>"+
                            "<h3>"+title+"</h3>"+
                            "<p>"+author+"<span></span> </p>"+
                        "</a>"+
                        "<p>%placeHolder%"+
//                        	"<a href='#pjzjr' class='pjzjr'>评价转借人</a>"+
//                        	"<a href='#dndpj' class='pingjia'>Ta对你的评价</a>"+
                        "</p>"+
                    "</li>";
				var placeHolder ="";
				if(toCommentId == undefined){
					placeHolder += "<a fromUserid='"+loans[i].fromUserid+"' toUserid='"+loans[i].toUserid+"' fromNickname='"+loans[i].fromNickname+"' toNickname='"+loans[i].toNickname+"' historyId='"+loans[i].id+"' href='#pjjyr' class='pjzjr'>评价转借人</a>";
				}else{
					placeHolder += "<a style='color:#ccc' href='javascript:;' class='pjzjr'>您已作出评价</a>";
				}
				if(fromCommentId == undefined){
					placeHolder += "<a href='javascript:;' class='weipj'>Ta尚未评价</a>";
				}else{
					placeHolder += "<a commentId='"+fromCommentId+"' href='#dndpj' class='pingjia'>Ta对你的评价</a>";
				}
				li = li.replace("%placeHolder%",placeHolder);
				$("#outHistoryUl").append(li);
				coverCover();
			}
			$("#outHistoryUl a[href='#sjxqdt']").click(function(){
				loanDetail($(this));
			});
			$("#outHistoryUl a[href='#pjjyr']").click(function(){
				addOutComment($(this));
			});
			$("#outHistoryUl a[href='#dndpj']").click(function(){
				showComment($(this));
			});
		}
	});
}
function addOutComment(data){
	$("#pjjyr .tijiao").unbind("click");
	$("#pjjyr .tijiao").click(function(){
		var timeRank = $("#pjjyr #shoushi input.cur").length;
		var desRank = $("#pjjyr #miaosu input.cur").length;
		$.ajax({
			url :interfaceMobileUrl+"/addOutComment.json?userid="+userid+"&key="+userkey,
			jsonp: "callback",
		    dataType: "jsonp",
		    data:{
		    	 fromUserid:data.attr("fromUserid"),     
		    	 toUserid  :data.attr("toUserid"),       
		    	 desRank   :   desRank,
		    	 timeRank  :   timeRank,
		    	 fromNickname:data.attr("fromNickname"), 
		    	 toNickname  :data.attr("toNickname"),    
		    	 historyId   :data.attr("historyId")     
		    },
			error:function(){
				xfAlert("是不是网络不通啊");
			},
			success:function(data){
				if(data == "1"){
					xfAlert("评价成功");
					outHistory();
					$.ui.loadContent("#zjiels",false,false,"up");
				}
			}
		});
	});
}
$(function(){
	$("a[href='#zjiels']").click(function(){
		if(userid ==null){
			xfAlert("请先登录");
			$.ui.loadContent("#denglu",false,false,"up");
			return false;
		}
		outHistory(userid);
	});
});

